<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>条件渲染 - 广告</title>
    <style>
        #ad{
            height:100px;
            background: linear-gradient(to right bottom, #cea, #4f6);
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">

        //声明一个变量
        let isVip = true; // is 是否  vip 贵宾

        //声明一个函数
        function showAd(){
            if(isVip){
                return null;
            }else{
                return <div id="ad"></div>;
            }
        }

        //创建虚拟 DOM   
        let vDOM = <div>
                {/*1. 第一种 &&*/}
                {!isVip && <div id="ad"></div>}
                {/*2. 第二种 三元表达式*/}
                {isVip ? null : <div id="ad"></div>}
                {/*3. 第三种 函数调用*/}
                {showAd()}
                {<div>abc</div>}
            </div>;

        //渲染
        ReactDOM.render(vDOM, document.querySelector("#root"));
    </script>

</body>
</html>